﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data;
using System.Data.SqlClient;

using BALayer;

namespace PGBT
{
    public partial class DanhMucChiTietSanPham : Form
    {
        private HangHoa db = null;
        private DataSet dsSP = null;
        
        public DanhMucChiTietSanPham()
        {
            InitializeComponent();
        }

        private void DanhMucSanPham_Load(object sender, EventArgs e)
        {
            db = new HangHoa();
            dsSP = db.DanhSachHangHoa();

            cbTenHang.DataSource = dsSP.Tables[0];
            cbTenHang.DisplayMember = "tenhang";
        }

        private void cbTenHang_SelectedIndexChanged(object sender, EventArgs e)
        {
            txtMaHang.Text = dsSP.Tables[0].Rows[cbTenHang.SelectedIndex].ItemArray[0].ToString();

            BindingSource bs = new BindingSource();
            bs.DataSource = db.ChiTietHangHoa().Tables[0];
            bs.Filter = "mahang='" + Convert.ToInt32(txtMaHang.Text) + "'";
            dgvHangHoa.DataSource = bs;
            dgvHangHoa.AutoResizeColumns();
        }

        private void dgvHangHoa_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
        }
    }
}
